﻿using Application.Dto;
using Application.IAppSrevices;
using AutoMapper;
using Domain.Entitys;
using Domain.Repositorys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.AppSrevices
{
    public class EMRService : IEMRService
    {
        private readonly IMapper mapper;
        private readonly IEMRRepositoty eMRRepositoty;

        public EMRService(IMapper mapper,IEMRRepositoty eMRRepositoty)
        {
            this.mapper = mapper;
            this.eMRRepositoty = eMRRepositoty;
        }
        public async Task<int> EMRAddAsync(EMRAddDto eMRAddDto)
        {
            EMR emr = mapper.Map<EMR>(eMRAddDto);
            return await eMRRepositoty.EMRAddAsync(emr);
        }

        public async Task<int> EMRDeleteAsync(int id)
        {
            return await eMRRepositoty.EMRDeleteAsync(id);
        }

        public int EMRSelectCount()
        {
            return eMRRepositoty.EMRSelectCount();
        }

        public async Task<List<EMR>> EMRSelectFenye(int pageIndex, int pageSize)
        {
            return await eMRRepositoty.EMRSelectFenye(pageIndex, pageSize);
        }

        public Task<EMR> EMRSelectId(int id)
        {
            return eMRRepositoty.EMRSelectId(id);
        }

        public async Task<int> EMRUpdateAsync(EMRUpdateDto eMRUpdateDto)
        {
            EMR emr = mapper.Map<EMR>(eMRUpdateDto);
            return await eMRRepositoty.EMRUpdateAsync(emr);
        }
    }
}
